package code4;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

    public static void main(String[] args) {

        ServerSocket ss = null;
        try {
            ss = new ServerSocket(8888);
            while(true){
                System.out.println("等待客户端的连接请求...");
                Socket s = ss.accept();
                System.out.println("客户端"+s.getInetAddress()+"连接成功！");
                new ServerThread(s).start();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(null!=ss){
                try {
                    ss.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
